'use strict';

var smart = require('../address/address_parse');
const Controller = require('egg').Controller;


class HomeController extends Controller {
  async index() {
    const { ctx } = this;

    const createRule = {
      address: { type: 'array' }
    };

    try{
      ctx.validate(createRule)
    }catch (err) {
      ctx.body = {
        error: "参数错误" ,
        code: 500
      };
      return;
    }

    let address = ctx.request.body.address;
    let parse_list = [];

    address.forEach((item) =>{
       parse_list.push(smart(item));
    })




    ctx.body = parse_list;
  }
}

module.exports = HomeController;
